package com.denlaku.longan.service.impl;

import com.denlaku.longan.qo.ObjPermQuery;
import com.denlaku.longan.qo.Query;
import com.denlaku.longan.repository.ObjectTagSetRepository;
import com.denlaku.longan.service.ObjectTagRelService;
import com.denlaku.longan.service.ObjectTagSetService;
import com.denlaku.longan.vo.ObjectTagSet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tianx
 */
@Slf4j
@Service
public class ObjectTagSetServiceImpl implements ObjectTagSetService {
    @Autowired
    private ObjectTagSetRepository objectTagSetRepository;

    @Autowired
    private ObjectTagRelService objectTagRelService;

    @Override
    public void add(ObjectTagSet objectTagSet) {
        objectTagSetRepository.add(objectTagSet);
    }

    @Override
    public void update(ObjectTagSet objPermTagSet) {
        objectTagSetRepository.update(objPermTagSet);
    }

    @Override
    public ObjectTagSet get(Query query) {
        return objectTagSetRepository.get(query);
    }

    @Override
    public List<ObjectTagSet> list(Query query) {
        return objectTagSetRepository.list(query);
    }

    @Override
    public List<ObjectTagSet> search(Query query) {
        return objectTagSetRepository.search(query);
    }

    @Override
    public void delete(ObjPermQuery query) {
        objectTagSetRepository.delete(query);

        query.setTagSetId(query.getId());
        query.setId(null);
        objectTagRelService.delete(query);
    }
}
